<?php
$this->breadcrumbs=array(
	'Quản lý người dùng',
);

?>
<script>
$(document).ready(function(){
	
	
	
	$('#search').keyup(function(){
		
		var data = $(this).val();
		//alert(data);
		$.ajax({
            url: 'SuggestPerson',
            type: 'POST',
            dataType: 'JSON',
            data: {term: data},
            success: function(result){
            //$('#price').html(result.data.gia);
            //alert(result[0].username);
            $('#table tr').each(function() {
				//alert($(this).index());
				$(this).hide();
				if($(this).index()==0)
				{
					$(this).show();
				}
				for(var i=0;i<result.length;i++)
			    if($(this).find(".username").html() == result[i].username)
			    {
					$(this).show();
				}  
			    
	 		});
         //   alert($('table#table tr td').length;
            }
    		});
		});
	
});

function showAction(user, action, url){
	$("#duser").val(user);
	$("#daction").val(action);
	$("#durl").val(url);
}
</script>

<?php 

$trangthai = array(
   array('value'=> 0, 'label' => "Đã block"),
    array('value'=> 1, 'label' => "Đang active"),
);

 $this->widget('bootstrap.widgets.TbGridView', array(
    'type'=>'striped bordered condensed',
    'dataProvider'=>$model->search(),
 	'filter'=>$model,
   // 'template'=>"{items}",
    'columns'=>array(
 		array('name'=>'username', 'header'=>'Username',  'htmlOptions'=>array('style'=>'vertical-align:middle !important;')),
 		array('name'=>'hoten', 'header'=>'Họ tên',  'htmlOptions'=>array('style'=>'vertical-align:middle !important;')),
 		array('name'=>'email', 'header'=>'Email', 'htmlOptions'=>array('style'=>'vertical-align:middle !important;')),
 		array('name'=>'diachi', 'header'=>'Địa chỉ', 'htmlOptions'=>array('style'=>'vertical-align:middle !important;')),
 		array('name'=>'dienthoai', 'header'=>'Điện thoại',  'htmlOptions'=>array('style'=>'vertical-align:middle !important;')),
 		 array('name'=>'trangthai','filter'=>CHtml::listData($trangthai,'value','label'),'type' => 'raw','header'=>'Thao tác', 'value'=>'UserUtils::getAdminAction($data)', 'htmlOptions'=>array('style'=>'width:60px;vertical-align:middle !important;')),
        
        array('class'=>'bootstrap.widgets.TbButtonColumn','template'=>'<div>{view}{delete}</div>',
          'htmlOptions'=>array('style'=>''),
        'buttons'=>array(
         'view'=>array( 
                'confirm'=>'Bán muốn tiếp tục thay đổi mật khẩu không? user: $data->username','url'=>'Yii::app()->createUrl("user/resetpassword", array("id"=>$data->id))','label'=>'Reset mật khẩu.','imageUrl'=>Yii::app()->request->baseUrl.'/images/view.png','options'=>array('class'=>'delete')),
        ))
      ),
)); ?>

<?php 

function getLinkresetpass($data){
	return CHtml::link('Reset', array('user/resetpassword', 'id' => $data->id));
}

function getLinkxoapass($data){
	return CHtml::link('Xóa', array('user/Delete', 'id' => $data->id));
}

?>

<?php $this->beginWidget('bootstrap.widgets.TbModal', array('id'=>'myModal')); ?>
 
<div class="modal-header">
    <a class="close" data-dismiss="modal">&times;</a>
    <h4>Thông báo xác nhận</h4>
</div>
 
<div class="modal-body">
    <p>User: <span id='duser'></span></p>
    <p>Thao tác: <span id='daction'></span></p>
</div>
 
<div class="modal-footer">
    <?php $this->widget('bootstrap.widgets.TbButton', array(
        'type'=>'primary',
        'label'=>'Tiếp tục',
        'url'=>'#',
        'htmlOptions'=>array('data-dismiss'=>'modal', 'id'=>'durl'),
    )); ?>
</div>
 
<?php $this->endWidget(); ?>
